import java.util.Arrays;

public class t322 {//零钱兑换 递归/动态规划

    public static void main(String[] args) {
        int arr[] = {2,5,7};
        int count = 27;
        int m = arr.length;

        int dp[] = new int [28];
        dp[0] = 0;
        for(int i =1;i<=27;i++){
            dp[i] = Integer.MAX_VALUE;
            for(int j =0; j<arr.length; j++){
                if(i>=arr[j] && dp[i-arr[j]]!=Integer.MAX_VALUE){
                    dp[i] = Math.min(dp[i],dp[i-arr[j]]+1);
                ;}
            }
        }
        System.out.println(dp[27]);




































        /*int dp[] = new int[count+1];
        int n = arr.length;
        dp[0] = 0;
        int min;
        for(int i =1; i<=count;i++){
            dp[i] = Integer.MAX_VALUE;
            for(int j =0; j<n; j++){
                if(i-arr[j]>=0 && dp[i-arr[j]]!=Integer.MAX_VALUE){
                    dp[i] = Math.min(dp[i-arr[j]]+1,dp[i]);
                }
            }
        }
        if(dp[count] == Integer.MAX_VALUE){
            min = -1;
        }else{
            min = dp[count];
        }
        System.out.println(min);*/






        //System.out.print(Arrays.toString(dp)+" ");
        //System.out.println(f(27));
        //System.out.println(Math.min(Integer.MAX_VALUE,Integer.MAX_VALUE));
        /*int min = f(1);
        if(min == Integer.MAX_VALUE-1){
            System.out.println(-1);
        }else{
            System.out.println(min);
        }*/

    }
    /*public static int f(int count){
        if(count ==0){
            return 0;
        }
        int res = Integer.MAX_VALUE-1;
        if(count>=7){
            res =  Math.min(f(count-7)+1,res);
        }
        if(count>=5){
            res =  Math.min(f(count-5)+1,res);
        }
        if(count>=2){
            res = Math.min(f(count-2)+1,res);
        }
        return res;
    }*/
    public static int coinChange(int[] coins, int amount) {
        int dp[] = new int[amount+1];
        dp[0] = 0;
        for(int i =1 ; i <=amount; i++){
            dp[i] = Integer.MAX_VALUE;
            for(int j =0; j<coins.length; j++){
                if(i-coins[j]>=0 && dp[i-coins[j]]!=Integer.MAX_VALUE){
                    dp[i] = Math.min(dp[i-coins[j]]+1,dp[i]);
                }
            }
        }
        if(dp[amount] == Integer.MAX_VALUE){
            return -1;
        }else{
            return dp[amount];
        }
    }
}
